import React, { PureComponent } from "react";
import { connect } from "dva";
import { Card } from "antd";
import Pie   from '../../../components/Charts/Pie';




export default class FaultChart extends PureComponent {
  constructor(props) {
    super(props);

  }

  componentDidMount() {

  }



  render() {
    const { pieData, title, faultType } = this.props;

    const FormatData = pieData ? pieData.reduce((arr, curr) => {
      if(curr.faultType && faultType[parseInt(curr.faultType)-1]){
        return arr.concat([{
          x: faultType[parseInt(curr.faultType)-1],
          y: curr.repairTimes,
        }]);
      }else{
        return arr.concat([]);
      }
    }, []) : [];


    return (

        <Pie
          hasLegend
          title={title}
          data={FormatData}
          height={350}
          inner={0}
        />

    );
  }
}
